<html>
<head><meta charset="utf-8"><title>Debugging segfault in LLVM · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html">Debugging segfault in LLVM</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232377572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232377572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232377572">(Mar 30 2021 at 05:56)</a>:</h4>
<p>Does anybody have advice for debugging a segfault inside LLVM? Over in project-portable-simd, we have one that only happens in release builds on aarch64. It looks to me like a null pointer deref. Unfortunately, I cant find a way to get full debuginfo in LLVM and rustc:</p>
<p>I did a build with these settings <a href="https://gist.github.com/thomcc/46c13e4e14ae8843a175208a2833c8ba">https://gist.github.com/thomcc/46c13e4e14ae8843a175208a2833c8ba</a>, but it wasn't quite enough. I have function names and the like, obviously, but I don't have much more, e.g. everything else is assembly. This is on an aarch64-apple-darwin machine, but I gather it happens on any aarch64 (which makes sense given the backtrace)</p>
<p>Link to the thread, containing the backtrace that we do have: <a href="#narrow/stream/257879-project-portable-simd/topic/2021-03-29.20Meeting/near/232369790">https://rust-lang.zulipchat.com/#narrow/stream/257879-project-portable-simd/topic/2021-03-29.20Meeting/near/232369790</a></p>



<a name="232378901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232378901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232378901">(Mar 30 2021 at 06:17)</a>:</h4>
<p>Use <code>--emit llvm-ir</code> to get a .ll file. Then pass that to <code>llc -march=aarch64 -O3 foo.ll</code> to see if you can reproduce the crash.</p>



<a name="232378968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232378968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232378968">(Mar 30 2021 at 06:18)</a>:</h4>
<p>Use the <code>llc</code> binary from the rustc build so you get the same LLVM as rustc.</p>



<a name="232379327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232379327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232379327">(Mar 30 2021 at 06:23)</a>:</h4>
<p>Once that's confirmed then use <code>bugpoint</code> to reduce the LLVM IR. I've never used it before, but you can find some docs on the LLVM website about it.</p>



<a name="232379626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232379626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232379626">(Mar 30 2021 at 06:27)</a>:</h4>
<p>hmm, i see, i'd do --emit llvm-ir on the debug build?</p>



<a name="232380592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232380592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232380592">(Mar 30 2021 at 06:39)</a>:</h4>
<p>nm i think i have it</p>



<a name="232380612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232380612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232380612">(Mar 30 2021 at 06:39)</a>:</h4>
<p>Use --emit llvm-ir on the build that causes the crash.</p>



<a name="232380629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232380629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232380629">(Mar 30 2021 at 06:39)</a>:</h4>
<p>yeah</p>



<a name="232380720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232380720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232380720">(Mar 30 2021 at 06:40)</a>:</h4>
<p>that segfaults, but if i remove the -C opt-level=3 from the rustc invocation i get a .ll file. unfortunately, <code>llc -march=aarch64 -O3 &lt;that file&gt;.ll</code> does not segfault</p>



<a name="232381542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232381542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232381542">(Mar 30 2021 at 06:50)</a>:</h4>
<p>I don't know, I'll defer to someone who's more familiar with LLVM :/</p>



<a name="232381772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232381772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232381772">(Mar 30 2021 at 06:54)</a>:</h4>
<p>no worries, thanks for the pointers either way</p>



<a name="232385070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232385070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232385070">(Mar 30 2021 at 07:29)</a>:</h4>
<p>Can you pass <code>-Cno-prepopulate-passes</code> to rustc? That will ensure that the LLVM ir is completely unoptimized. And can you try to reproduce the crash with <code>-Ccodegen-units=1</code>? (this is implicit when using <code>--emit llvm-ir</code>)</p>



<a name="232385079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232385079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232385079">(Mar 30 2021 at 07:29)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span></p>



<a name="232385997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232385997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232385997">(Mar 30 2021 at 07:39)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133247">bjorn3</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Debugging.20segfault.20in.20LLVM/near/232385070">said</a>:</p>
<blockquote>
<p>Can you pass <code>-Cno-prepopulate-passes</code> to rustc? That will ensure that the LLVM ir is completely unoptimized. And can you try to reproduce the crash with <code>-Ccodegen-units=1</code>? (this is implicit when using <code>--emit llvm-ir</code>)</p>
</blockquote>
<p>hmm:</p>
<ul>
<li>I can still repro the crash with -Ccodegen-units=1.</li>
<li>-Cno-prepopulate-passes doesnt seem to repro the crash</li>
<li>passing the result of it to llc doesn't seem to repro the crash either</li>
</ul>



<a name="232386017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232386017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232386017">(Mar 30 2021 at 07:39)</a>:</h4>
<p>Note: the crash only happens for optimized builds</p>



<a name="232386089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232386089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232386089">(Mar 30 2021 at 07:40)</a>:</h4>
<p>debug builds do not repro it, and so far, passing the result of the IR from a debug build to <code>llc -O3</code> doesn't repro either</p>



<a name="232386136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232386136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232386136">(Mar 30 2021 at 07:40)</a>:</h4>
<p>(sorry for the delay, will be in and out for the next hour or so, then probably will be headed to bed if i know whats good for me, but will be investigating more tomorrow)</p>



<a name="232392880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232392880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232392880">(Mar 30 2021 at 08:48)</a>:</h4>
<p>(FWIW I checked and every -Copt-level other than 1 causes the error, including s and z)</p>



<a name="232413794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232413794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232413794">(Mar 30 2021 at 12:07)</a>:</h4>
<p>Try <code>llc -O3 -march=aarch64 -fast-isel=0 -global-isel=false</code></p>



<a name="232413938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232413938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232413938">(Mar 30 2021 at 12:08)</a>:</h4>
<p>Also make sure you're using <code>build/x86_64-unknown-linux-gnu/llvm/bin/llc</code> from your rustc build, not the system llc.</p>



<a name="232422852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232422852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232422852">(Mar 30 2021 at 13:15)</a>:</h4>
<p>you can get LLVM to print out a ton of info with <code>-print-before-all</code> or <code>-print-after-all</code> or <code>-debug</code>.</p>



<a name="232422892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232422892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232422892">(Mar 30 2021 at 13:15)</a>:</h4>
<p>the last one requires assertions-enabled build to be useful.</p>



<a name="232423008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232423008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232423008">(Mar 30 2021 at 13:16)</a>:</h4>
<p>(from rustc you can pass these in via <code>-Cllvm-args</code>)</p>



<a name="232425676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232425676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232425676">(Mar 30 2021 at 13:33)</a>:</h4>
<p>Also, note that the assert might be occurring in the optimizer and not the backend, in which case you'd use <code>opt</code> to reproduce, not <code>llc</code>. This information is also something you would be able to derive from <code>-print-before-all</code> and/or <code>-debug</code> output.</p>



<a name="232425930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232425930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232425930">(Mar 30 2021 at 13:34)</a>:</h4>
<p>Ah, I didn't see the backtrace, its in the backend. But then you also see an assert when you just <code>--emit=llvm-ir</code>… shrug.</p>



<a name="232429111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232429111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232429111">(Mar 30 2021 at 13:56)</a>:</h4>
<p>I would also recommend trying <code>-Csave-temps</code> and then using preserved <code>*.bc</code> files, rather than using <code>--emit llvm-ir</code>.</p>



<a name="232449487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232449487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232449487">(Mar 30 2021 at 15:54)</a>:</h4>
<p>maybe your crash is in the passes of <code>opt</code> instead? (or in <code>llc</code> but dependent on <code>opt</code> running first)</p>



<a name="232450499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232450499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232450499">(Mar 30 2021 at 15:59)</a>:</h4>
<p>The linked backtrace is in shows the issue is in <code>llvm::AArch64TargetLowering</code>.</p>



<a name="232450629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232450629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232450629">(Mar 30 2021 at 16:00)</a>:</h4>
<p>ah ok -- but it still may need <code>opt</code> passes first</p>



<a name="232457385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232457385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232457385">(Mar 30 2021 at 16:41)</a>:</h4>
<p>(Oops, nevermind, I got confused by zulip and didn't see the rest of the conversation.)</p>



<a name="232519641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232519641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232519641">(Mar 31 2021 at 00:45)</a>:</h4>
<p>(it seems like this repros on non-aarch64, and given that this wasn't my patch in the first place, I think <span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> might be the one following up here)</p>



<a name="232830166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232830166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232830166">(Apr 01 2021 at 21:51)</a>:</h4>
<p>I've reduced the crashing source code to a pretty minimal example: <a href="https://github.com/calebzulawski/llvm-aarch64-codegen-crash">https://github.com/calebzulawski/llvm-aarch64-codegen-crash</a><br>
Interestingly, my minimal example doesn't crash with <code>-Ccodegen-units=1</code>.<br>
Anyway, I can tell which CGU is failing since it's missing the final object file from <code>-Csave-temps</code>.  I have the following files:</p>
<div class="codehilite"><pre><span></span><code>bug-1974b6bb1d213572.bug.dco7g2um-cgu.6.rcgu.no-opt.bc
bug-1974b6bb1d213572.bug.dco7g2um-cgu.6.rcgu.thin-lto-after-import.bc
bug-1974b6bb1d213572.bug.dco7g2um-cgu.6.rcgu.thin-lto-after-internalize.bc
bug-1974b6bb1d213572.bug.dco7g2um-cgu.6.rcgu.thin-lto-after-patch.bc
bug-1974b6bb1d213572.bug.dco7g2um-cgu.6.rcgu.thin-lto-after-rename.bc
bug-1974b6bb1d213572.bug.dco7g2um-cgu.6.rcgu.thin-lto-after-resolve.bc
bug-1974b6bb1d213572.bug.dco7g2um-cgu.6.rcgu.thin-lto-input.bc
</code></pre></div>
<p>Does anyone know in what order they're produced/which is the final version that's finally compiled?</p>



<a name="232830353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232830353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232830353">(Apr 01 2021 at 21:53)</a>:</h4>
<p>the phases are all listed here -- <a href="https://github.com/rust-lang/rust/blob/d474075a8f28ae9a410e95d849d009006db4b176/compiler/rustc_codegen_llvm/src/back/lto.rs#L780-L877">https://github.com/rust-lang/rust/blob/d474075a8f28ae9a410e95d849d009006db4b176/compiler/rustc_codegen_llvm/src/back/lto.rs#L780-L877</a></p>



<a name="232830402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232830402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232830402">(Apr 01 2021 at 21:54)</a>:</h4>
<p>*-after-patch was the last thing llvm didn't segfault on, and presumably it segfaulted while running optimization passes over that input</p>



<a name="232830755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232830755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232830755">(Apr 01 2021 at 21:57)</a>:</h4>
<p>Thanks, that explains why each of these bc files compile fine with llc</p>



<a name="232832432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232832432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232832432">(Apr 01 2021 at 22:12)</a>:</h4>
<p><code>opt</code> doesn't seem to have any trouble with it (though I'm not sure I'm using the right incantation of flags to match what rustc is doing, or if that's even possible from the cli)</p>



<a name="232832675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232832675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232832675">(Apr 01 2021 at 22:15)</a>:</h4>
<p>Unfortunately I'm not sure that it's possible from the CLI to run the exact set of passes since it's pretty specific to ThinLTO. I have had some success in the past though running specific sets of passes one after another to get it to segfault. Sometimes it can be really tricky though</p>



<a name="232969090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232969090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232969090">(Apr 03 2021 at 01:01)</a>:</h4>
<p>In case anyone was curious, I was successfully able to reproduce it with just <code>opt --aarch64-simdinstr-opt</code>.  I tried reducing it with <code>bugpoint</code> but it spit out the same bytecode (perhaps I did something wrong?).  Once my LLVM bugzilla account is approved I'll submit the crash.  Thanks everyone for all the help!</p>



<a name="232969310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232969310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232969310">(Apr 03 2021 at 01:05)</a>:</h4>
<p>Happy to attempt a reduction if you share the bc</p>



<a name="232970682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/232970682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#232970682">(Apr 03 2021 at 01:32)</a>:</h4>
<p>Thanks, here's the bc <a href="/user_uploads/4715/kazzgi9Iv6dG0q-VQgiZpvCL/bug.bc">bug.bc</a></p>



<a name="233303412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/233303412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#233303412">(Apr 06 2021 at 11:36)</a>:</h4>
<p>Sorry it took me a while to get back to this:</p>
<div class="codehilite"><pre><span></span><code>; RUN: opt --aarch64-simdinstr-opt -mtriple=aarch64 &lt; %s

define void @banana() {
  ret void
}
</code></pre></div>
<p>still reproduces.</p>



<a name="233303420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/233303420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#233303420">(Apr 06 2021 at 11:37)</a>:</h4>
<p>do you want me to report this upstream, or would you rather do that yourself?</p>



<a name="233304114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/233304114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#233304114">(Apr 06 2021 at 11:44)</a>:</h4>
<p>Huh, much simpler, thanks!  Feel free to report it yourself if you want, doesn't matter much to me.  I'll file the rust/stdsimd issue</p>



<a name="233380407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/233380407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#233380407">(Apr 06 2021 at 20:06)</a>:</h4>
<p><a href="https://bugs.llvm.org/show_bug.cgi?id=49867">https://bugs.llvm.org/show_bug.cgi?id=49867</a></p>



<a name="233408147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/233408147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#233408147">(Apr 06 2021 at 23:43)</a>:</h4>
<p>Thanks! Looking at that backtrace, I wonder if this is possibly a different bug.  I could only reproduce it from rustc with 64-element vectors and it was crashing in vector code, so we may have to revisit eventually</p>



<a name="233994369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/233994369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#233994369">(Apr 10 2021 at 22:29)</a>:</h4>
<p>The reason reduction results are different because I think the initial reproduction information is already giving a different crash.</p>



<a name="233994377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/233994377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#233994377">(Apr 10 2021 at 22:29)</a>:</h4>
<p>so yeah its 2 distinct issues.</p>



<a name="233994395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/233994395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#233994395">(Apr 10 2021 at 22:29)</a>:</h4>
<p>I'm not able to reproduce the one reported in <a href="https://github.com/rust-lang/rust/issues/84020">https://github.com/rust-lang/rust/issues/84020</a> this needs significantly more self contained reproduction instructions.</p>



<a name="234028392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Debugging%20segfault%20in%20LLVM/near/234028392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Debugging.20segfault.20in.20LLVM.html#234028392">(Apr 11 2021 at 08:47)</a>:</h4>
<p>FWIW what I do in this case is to run with -C save-temps and then do something like <code>for f in out/*.bc; do echo $f; build/.../llc -O3 &lt; $f &gt;/dev/null; done</code> in the hope that it crashes on one of the files.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>